/*:
* @plugindesc 楓之舞功能 - 行走圖近大遠小
* @author 老饕
* @version 1.0.0
* @date 3/21/2020
* 
* @help
* 行走圖近大遠小功能
* 
* 地圖示籤
* <Scale: upperScale, lowerScale>
* 指定角色在地圖最上方和地圖最下方時的縮放比例。
*/
var Imported = Imported || {};
Imported.SWDA_CharacterPerspective = true;

var SWDA_CharacterPerspective = SWDA_CharacterPerspective || {};
var params = PluginManager.parameters("SWDA_CharacterPerspective");


// 補充尺寸
SWDA_CharacterPerspective.spriteCharacterInitMembers = Sprite_Character.prototype.initMembers;
Sprite_Character.prototype.initMembers = function() {
    SWDA_CharacterPerspective.spriteCharacterInitMembers.call(this);
    this._zoomRate = 1;
};
// 補充更新尺寸
SWDA_CharacterPerspective.spriteCharacterUpdate = Sprite_Character.prototype.update;
Sprite_Character.prototype.update = function() {
	this.updateZoomRate();
    SWDA_CharacterPerspective.spriteCharacterUpdate.call(this);

};
// 更新放大率
Sprite_Character.prototype.updateZoomRate = function() {
	
	if($dataMap.meta && $dataMap.meta["Scale"]){
        var data = $dataMap.meta["Scale"].split(",");
        if(data.length >= 2){
			var upperScale = Number(data[0])||1;
			var lowerScale = Number(data[1])||1;
			this._zoomRate = (this._character._realY / $dataMap.height) * (lowerScale - upperScale) + upperScale;
        }

    }
};
// 更新行走圖、氣泡尺寸
SWDA_CharacterPerspective.spriteCharacterUpdatePosition = Sprite_Character.prototype.updatePosition;
Sprite_Character.prototype.updatePosition = function() {
	SWDA_CharacterPerspective.spriteCharacterUpdatePosition.call(this);
	this.scale.x = this._zoomRate;
	this.scale.y = this._zoomRate;
};

SWDA_CharacterPerspective.spriteCharacterUpdateBalloon = Sprite_Character.prototype.updateBalloon;
Sprite_Character.prototype.updateBalloon = function() {
	SWDA_CharacterPerspective.spriteCharacterUpdateBalloon.call(this);
	if (this._balloonSprite) {
		this._balloonSprite.scale.x = this._zoomRate;
		this._balloonSprite.scale.y = this._zoomRate;
		this._balloonSprite.y = this.y - (this.height-20) * this._zoomRate;
	}
};
